package dashboard.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

/**
 * 
 * simple introduction
 * 
 * <p>
 * detailed comment
 * 
 * @author guolu 2015-1-26
 * @see
 * @since 1.0
 */
public class DNumberUtils {


	public static String format(int n) {
		return Integer.toString(n);
	}

	public static String format(double d) {

		return String.format("%.2f", d);

	}

	public static double formatDouble(double d) {
		BigDecimal bg = new BigDecimal(d);
		return bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
	}
	
	// 浮点，千分位分隔，两位小数
	private static  DecimalFormat df = new DecimalFormat("0.00");
	public static double trans2Float(double num) {
		if (num == 0) {
			return 0;
		}
		return Double.valueOf(df.format(num));
	}
	public static void main(String[] args) {
//		System.out.println(formatDouble(1457));
		System.out.println(trans2Float(15467.4943667356569));
		String string="12341.2";
		StringUtils.isNumeric(string);
		NumberUtils.isNumber(string);
	}
}
